$(function () {
    $("#add").on("click", function () {
        if ($("#name").val() == "" || $("#score").val() == "" || $("#money").val() == "") {
            alert("请输入信息");
        } else {
            var local = getData();
            local.push({
                yName: $("#name").val(),
                score: $("#score").val(),
                money: $("#money").val()
            });
            setData(local);
            load();
            $("#name").val("");
            $("#score").val("");
            $("#money").val("");
        }
    });

    function getData() {
        var data = localStorage.getItem("list");
        if (data !== null) {
            return JSON.parse(data);
        } else {
            return [];
        }
    };

    function setData(data) {
        localStorage.setItem("list", JSON.stringify(data));
    };

    function load() {
        $.each(getData(), function (i, ele) {
            $("#list").prepend(`<div class="one editMode">
            <span class="item">
              <span class="info">${ele.yName}</span>
            </span>
            <span class="item">
              <span class="info">${ele.score}</span>
            </span>
            <span class="item">
              <span class="info">${ele.money}</span>
            </span>
            <span class="item">
              <i class="del"></i>
            </span>
          </div>`);
        });
    }
})